<?php

namespace Users\Form;

use Zend\Form\Form;
//use Zend\InputFilter;
//use Zend\Validator\File\Exists;

class UploadImageForm extends Form {
	
	public function __construct($name = null)
	{
		parent::__construct('uploadimageform');
		$this->setAttribute('method', 'post');
		$this->setAttribute('enctype','multipart/form-data');
			
		$this->add(array(
				'name' => 'id',
				'type' => 'Hidden',
		));
	
		$this->add(array(
				'name' => 'filename',
				'attributes' => array(
						'type' => 'file',
				),
				
				'options' => array(
						'label' => 'Image Upload',
				),
				//'validators' => array(
				// array(  'name' => 'Exists',
				// 		'options' => array(
				// 				'directory' => '/home/bupiotr/.apps/http/__default__/0/Zf_2downloads/1.0.0/data/uploads_images/'
				// 		)
				// )
				//),
		));
	
		$this->add(array(
				'name' => 'label',
				'attributes' => array(
						'type' => 'text',
				),
				'options' => array(
						'label' => 'Image Discription',
				),
				//'validators' => array(
				//		array(
				//				'name' => 'StringLength',
				//				'options' => array(
				//						'encoding' => 'UTF-8',
				//						'min' => 2,
				//						'max' => 140,
				//				),
				//		),
				//),
		));
		
		$this->add(array(
				'name' => 'thumbnail',
				'attributes' => array(
						'type' => 'text',
				),
				'options' => array(
						'label' => 'Image Discription',
				),
		));
	
		$this->add(array(
				'name' => 'user_id',
				'type' => 'hidden',
		));
		
		$this->add(array(
				'name' => 'override',
				'type' => 'checkbox',
				'options' => array('unchecked_value' => 'not_override','checked_value' => 'override','label'=>'Override existing file?'
				),
		
		));
		 
		$this->add(array(
				'name' => 'submit',
				'type' => 'submit',
				'attributes' => array('value' => 'Upload Now',
				),
	
		));
		
		
		//*************************filters and validators***********************
		//$inputFilter = new InputFilter\InputFilter();
		//$fileInput = new \Zend\Validator\File\Exists('/home/bupiotr/.apps/http/__default__/0/Zf_2downloads/1.0.0/data/uploads_images');
		//$fileInput->setRequired(true);
		//if ($validator->isValid('/tmp/myfile.txt')) {
			// file is valid
		//}
		//$inputFilter->add($fileInput);
		
		//$this->setInputFilter($inputFilter);
		
	
	}
}

?>